﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ContractorEdit.aspx.cs" Inherits="Catering.yl.Daily.ContractorEdit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link href="../../../Style/ZHJG/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/zhezhao.js" type="text/javascript"></script>
    <script src="../../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../../../Style/center.css" />
    <script type="text/javascript">
        //显示添加
        function Add() {
            $("#txt_CName").val("");
            $("#txt_LinkId").val("");
            $("#txt_CTel").val("");
            $("#txt_CAddress").val("");
            $("#txt_CState").val("");
            $("#txt_CDesc").val("");
            $("#btnEdit").hide();
            $("#btnAdd").show();
            divshow("main", "bg");
        }
        //添加数据
        function btn_Add() {
            var txt_CName = $("#txt_CName").val();
            var txt_LinkId = $("#txt_LinkId").val();
            var txt_CTel = $("#txt_CTel").val();
            var txt_CAddress = $("#txt_CAddress").val(); 
            var txt_CState = $("#txt_CState").val();
            var txt_CDesc = $("#txt_CDesc").val();
            var sel = document.getElementById("Slt1");
            var ContraType = sel.options[sel.selectedIndex].value;            
            var hdn_useDate = $("#hdn_useDate").val();
            var hdn_currentClassID = $("#hdn_currentClassID").val();
            var hdn_currentGroupID = $("#hdn_currentGroupID").val();
            $.ajax({
                type: "Post",
                url: "ContractorEdit.aspx/Add",
                data: "{'CName':'" + txt_CName + "','LinkId':'" + txt_LinkId + "','CTel':'" + txt_CTel + "','CAddress':'" + txt_CAddress + "','CState':'" + txt_CState + "','CDesc':'" + txt_CDesc + "','CType':'" + ContraType + "','hdn_useDate':'" + hdn_useDate + "','hdn_currentClassID':'" + hdn_currentClassID + "','hdn_currentGroupID':'" + hdn_currentGroupID + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",

                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                }
            });
        }
        function Edit(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "ContractorEdit.aspx/Get",
                data: "{'_id':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_id").val(data.d[0] == null ? "" : data.d[0]);
                    $("#txt_CName").val(data.d[1] == null ? "" : data.d[1]);
                    var sel = document.getElementById("Slt1");
                    sel.options[sel.selectedIndex].text = data.d[2] == null ? "" : data.d[2];
                    $("#txt_LinkId").val(data.d[3] == null ? "" : data.d[3]);
                    $("#txt_CTel").val(data.d[4] == null ? "" : data.d[4]);
                    $("#txt_CAddress").val(data.d[5] == null ? "" : data.d[5]);
                    $("#txt_CState").val(data.d[6] == null ? "" : data.d[6]);
                    $("#txt_CDesc").val(data.d[7] == null ? "" : data.d[7]);

                    $("#btnEdit").show();
                    $("#btnAdd").hide();
                    divshow("main", "bg");
                }
            });
        }        
        //修改数据
        function btn_Edit() {
            var txt_CName = $("#txt_CName").val();
            var txt_LinkId = $("#txt_LinkId").val();
            var txt_CTel = $("#txt_CTel").val();
            var txt_CAddress = $("#txt_CAddress").val();
            var txt_CState = $("#txt_CState").val();
            var txt_CDesc = $("#txt_CDesc").val();
            var sel = document.getElementById("Slt1");
            var ContraType = sel.options[sel.selectedIndex].value;
            var cid = $("#txt_id").val();

            $.ajax({
                type: "Post",
                url: "ContractorEdit.aspx/Edit",
                data: "{'_id':'" + cid + "','CName':'" + txt_CName + "','LinkId':'" + txt_LinkId + "','CTel':'" + txt_CTel + "','CAddress':'" + txt_CAddress + "','CState':'" + txt_CState + "','CDesc':'" + txt_CDesc + "','CType':'" + ContraType + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                }
            });
        }
        </script>
    <style type="text/css">        
        .btn{ width:83px;cursor:pointer; line-height:16px;  background:url(../../../Images/head_change_bg.gif) 0 0px no-repeat; border:0px;margin:0px; padding-top:0px; color:#285B8A;}
    
    </style>
    </head>
<body style="margin-top:0px; margin-left:0px">
    <form id="form1" runat="server">
        <input type="hidden" id="hdn_useDate" value='<%=Session["useDate"]%>' />
        <input type="hidden" id="hdn_currentClassID" value='<%=Session["ClassID"]%>' />
        <input type="hidden" id="hdn_currentGroupID" value='<%=Session["GroupID"]%>' />
        <div class="xxk_button1">
        <ul style="margin-top:0px;">
            <li id="li3_1" class="li_out li_over"><a href="ContractorEdit.aspx">承包商信息</a> </li>
            <li id="li3_2" class="li_out"><a href="DailyEMtce.aspx">日常维护保养</a> </li>
            <li id="li3_3" class="li_out""><a href="CtionSupervision.aspx">小型施工监管</a> </li>            
        </ul>
        </div>         
        <asp:HiddenField ID="HidID" runat="server" />  
        <div style="overflow:hidden; margin: 0 auto; width:998px;height: 46px; line-height: 40px; font-size: 13px; padding-top:0px;background: url(/Images/div_h1_bg_02.gif);"> 
            <input id="New" type="button" value="新增" style="float:right; margin:8px 5px" onclick="Add()" class="input_btn_a"/>
        </div>
        <div style="padding: 0px;text-align: center;height: 29px; margin-top:10px"> 
        <table cellpadding="0" cellspacing="0" style="overflow:hidden; margin: 0 auto;width:998px;border-left:1px solid #8b8888;border-top:1px solid #8b8888; text-align:center; margin:auto; font-size:12px;">
                <thead>
                    <tr style="background:url(../../../Images/th_02bg.gif) repeat-x 0px 0px; height:29px; ">
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">序号
                        </td >
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">承包商名称
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">业务类别
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">联系人
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">联系电话
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">地址
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">状态
                        </td>                        
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">评价或说明
                        </td>  
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">操作
                        </td>                       
                    </tr>
                </thead>
                <tbody>
                    <asp:Repeater ID="Rep_Plan" runat="server" OnItemCommand="Rep_Plan_ItemCommand">
                        <ItemTemplate>
                            <tr>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("tempId")%>                                    
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("CName")%>
                                </td>                                
                                 <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888;">
                                     <%#Eval("ContraType")%>
                                 </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("LinkId")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("Tel")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("Address")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("State")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("Description")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">                                    
                                    <asp:ImageButton ToolTip="承包商管理" ID="Button3" Height="16px" runat="server" ImageUrl="../../../Images/conEdit.gif" Text="证件与动态" CommandArgument='<%#Eval("id")%>' CommandName="ChangeSession" CssClass="btn"/>
                                    <img alt="" title="编辑" src="../../../Images/file.gif" style="cursor: pointer;" onclick="Edit('<%#Eval("id")%>')"/>                                    
                                    <asp:ImageButton ToolTip="删除" ID="ImageButton1" runat="server" ImageUrl="../../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                        CommandArgument='<%#Eval("id")%>' CommandName="del"/>
                                </td>                                                          
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
            </div>
        <!--弹出层-->
        <div id="bg" class="bg">
        </div>
        <div id="main" class="center_div" style="width: 400px; height: 300px; left:50%;top:10%;margin:-150px 0px 0px -200px; font-size:12px;">
            <div class="div_0207" style="width: 398px; margin: 0px;">
                <h1 style="width:388px">
                    <img src="../../../Images/cp_h1_03.gif"/>添加承包商</h1>
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td height="40" class="auto-style1">
                            承包商名称:
                        </td>
                        <td>
                            <asp:HiddenField ID="txt_id" runat="server" />  
                            <asp:TextBox ID="txt_CName" runat="server" CssClass="input_bg" Width="100px"></asp:TextBox>                          
                        </td>
                        <td width="85" height="40" align="right">业务类别:
                        </td>
                        <td width="65" height="40" align="right">
                            <select id="Slt1" style="width:110px;">
                                <option value="日常设备维护">日常设备维护</option> 
                                <option value="项目施工监管">项目施工监管</option>
                                <option value="终端外包业务">终端外包业务</option>
                            </select>
                        </td>                        
                    </tr>
                    <tr>
                        <td height="40" align="right" class="auto-style1">联系人:
                        </td>
                        <td>
                            <asp:TextBox ID="txt_LinkId" runat="server" CssClass="input_bg" Width="100px"></asp:TextBox>                          
                        </td>
                        <td width="85" height="40" align="right">联系电话:
                        </td>
                        <td>
                            <asp:TextBox ID="txt_CTel" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>                          
                        </td>               
                    </tr>
                    <tr>
                        <td height="40" align="right" class="auto-style1">地址:
                        </td>
                        <td>
                            <asp:TextBox ID="txt_CAddress" runat="server" CssClass="input_bg" Width="100px"></asp:TextBox>                          
                        </td>
                        <td width="85" height="40" align="right">状态:
                        </td>
                        <td>
                            <asp:TextBox ID="txt_CState" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>                          
                        </td>               
                    </tr>
                    <tr>
                        <td height="40" align="right" class="auto-style1">评价或说明:
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="txt_CDesc" runat="server" CssClass="input_bg" Width="295px" Height="62px" TextMode="MultiLine"></asp:TextBox>                          
                        </td>                                      
                    </tr>
                </table>
                <table width="100%">
                    <tr>
                        <td height="30" align="right">
                            <input type="button" id="btnAdd" onclick="btn_Add()" class="input_btn_a" value="提交" />
                            <input type="button" id="btnEdit" onclick="btn_Edit()" class="input_btn_a" value="提交" />
                        </td>
                        <td>
                            <input type="button" id="but_Close" onclick='divhidel("main", "bg")' class="input_btn_a"
                                value="关闭" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
          

    </form>
</body>
</html>
